home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / program / 177 / pascal / epasutil.doc < prev    next >
Encoding:
Text File  |  1987-09-16  |  50.9 KB  |  1,730 lines

  1.  
  2.                Eric's Pascal Utilities / EPasUtil
  3.                 Copyright 1986 by Eric W. Wedaa
  4.                         4620 E. 17th St
  5.                         Tucson AZ, 85711
  6.                           BIX: EWedaa
  7.                         CIS: 76515.2274
  8.                       ALL rights reserved.
  9.  
  10. Personal Pascal copyright 1985 by Optimized Systems Software, Inc.
  11.  
  12. FOR PERSONAL PASCAL VERSIONS 1.XX
  13.  
  14.      This is a Shareware program.  It is distributed freely in the 
  15. hopes  that  you  will  find it to be of some  use  to  you  while 
  16. programming  in  OSS  Personal  Pascal 1.XX.   It  is  NOT  to  be 
  17. distributed by any of the "Pay for a Public Domain disk" companies 
  18. that exist.  It may be distributed freely over any BBS or computer 
  19. service such as Compuserve or BIX.
  20.  
  21.      If  you find this program to be of use to you,  feel free  to 
  22. send  me  a check for my time  and  effort.  ($25.00  recomended.) 
  23. Please  include  the  version number and where  you  obtained  the 
  24. program from.   Program updates will be posted as they are written 
  25. and when people inform me of bugs or problems in the program.   If 
  26. this program does not work with your version of Pascal,  send me a 
  27. note, and I'll see what I can do about it.
  28.  
  29.      Partial  source code to this program has been placed  in  the 
  30. Public  Domain  as  EROUTINE.ARC  (Eric's  Routines  in   archived 
  31. format.)  If you use these routines,  I would appreciate it if you 
  32. could  send me a disk (Single of Double sided) with some  of  your 
  33. Pascal  routines,  and any Public Domain software that  you  have.  
  34. Please include my name in the opening credits of any program  that 
  35. uses these routines.
  36.  
  37.      Thank you,
  38.  
  39.      Eric W. Wedaa.
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.                 What is Eric's Pascal Utilities?
  47.       ====================================================
  48.  
  49.      Eric's Pascal Utilities is a collection of handy utilities 
  50.  
  51. that I've designed to help write Pascal programs.  Most of these 
  52.  
  53. are adaptations of various utilities that are available for 
  54.  
  55. programmers on other machines that I've grown used to.  When I 
  56.  
  57. started writing code on my ST at home, I realized how dependent I 
  58.  
  59. had become on them to write code.  Since they were not available, 
  60.  
  61. I decided to write them myself.
  62.  
  63.  
  64.            Who's Eric's Pascal Utilities for anyways?
  65.       ====================================================
  66.  
  67.      Well, if you program in Pascal, then this program is for you.  
  68.  
  69. But lets make sure of who you are.  Hopefully, you're familiar 
  70.  
  71. with the Atari ST and how it works.  I also hope that you aren't a 
  72.  
  73. beginning Pascal programmer anymore.  This program is most useful 
  74.  
  75. to people writing programs that are over a hundred or so lines 
  76.  
  77. long. 
  78.  
  79.  
  80.      By the way, you should be a person who cares enough about 
  81.  
  82. programming to want to write cleaner, as well as more stylish, and 
  83.  
  84. more efficient code.  That, I can help you with.  As you go 
  85.  
  86. through this article, I'll be pointing out how to best use the 
  87.  
  88. routines to write better code.  But it's still up to you to use 
  89.  
  90. what the program tells you.
  91.  
  92.  
  93.      The following chart presents a brief overview of the routines 
  94.  
  95. available to in Eric's Pascal Utilities.  This is mainly intended 
  96.  
  97. for those of you who will just skim the article, and then move on 
  98.  
  99. to explore on your own.  I know that's what I do 99% of the time.  
  100.  
  101. If you intend on reading the article straight through, and then 
  102.  
  103. using the program, you can skip this section.
  104.  
  105.  
  106.      --Listing Files:  This routine prints out a source code file 
  107.               to the printer.  Along the way to the printer, it 
  108.               adds the line number that the Compiler and the 
  109.               Cross Reference routine uses.
  110.  
  111.      --Showing Files:  The same as above, but to the screen 
  112.               instead.  Extremely helpful for deciding where to 
  113.               start your Listing.
  114.  
  115.      --Procedure I/O:  Sends a listing of all your routines, in 
  116.               the order declared to a text file called ".PRO".   
  117.               It includes all the parameters associated with the 
  118.               routine, as well as the line number it's declared 
  119.               on.
  120.  
  121.      --Cross Reference:  A sorted listing of all your identifiers, 
  122.               what they are, and their block level declared and 
  123.               used.  If you choose the Full Cross Reference 
  124.               option, You'll get a text file longer than your 
  125.               program file.  But it's extremely handy.
  126.  
  127.      --Fix Capitalization:  This routine goes through your source 
  128.               code and changes all of your capitalization.  You 
  129.               have eight word sets, and four choices of 
  130.               capitalization styles to choose from.
  131.  
  132.      --Format:  Basically, all it does is make a "Pretty Print" 
  133.               test file with the "FRM" or a "PRN" extension.   Go 
  134.               read the section on it in detail.
  135.  
  136.      --Statistics:  A quick run down on how often you use a 
  137.               given word in your program.
  138.  
  139.  
  140.                         What's on the disk
  141.        ====================================================
  142.  
  143.      There are 4 files on this disk.  They fall into three 
  144.  
  145. categories, EPASUTIL Program files, Documentation files, and 
  146.  
  147. Sample Program files.  They are:
  148.  
  149.  
  150.                           2 Program files
  151.      --EPASUTIL.PRG. The program.
  152.      --EPASUTIL.DAT. The program's data file.
  153.  
  154.                        1 Documentation files.
  155.      --READ.ME.      Last minute notes and corrections. 
  156.      --EPASUTIL.DOC  Program documentation
  157.  
  158.  
  159.                           Starting up.
  160.        ====================================================
  161.  
  162.      O.K.  You've double-clicked the EPASUTIL.PRG icon or the file 
  163.  
  164. name.  Now what?  Well, after the program has loaded and started 
  165.  
  166. running, you will get a message saying "Please Wait, Loading 
  167.  
  168. data."  Loading the data will take a couple of seconds.
  169.  
  170.  
  171.      After that's done, the screen will clear, and the title 
  172.  
  173. screen will appear.  Hit the Return key and you will then see the 
  174.  
  175. Main dialog box.  This is where you will choose options.  
  176.  
  177.  
  178.      To choose an option, just point and click on the button you 
  179.  
  180. want.  After you do that, the screen will clear, and the GEM File 
  181.  
  182. Selector box will appear.  If you choose the CANCEL button, you 
  183.  
  184. will be returned to the Main dialog box.  If you choose a valid 
  185.  
  186. file name, you will move on to the rest of that routine.
  187.  
  188.  
  189.                          Listing Files
  190.        ====================================================
  191.  
  192.  
  193.      This routine will print out your program file with the 
  194.  
  195. Compiler and Cross Reference line numbers printed in front of each 
  196.  
  197. line. Any line longer than 73 characters long will have the 
  198.  
  199. remaining part(s) indented and printed on the line below it.
  200.  
  201.  
  202.       The beauty of this really shows when you have just compiled 
  203.  
  204. a program, and have received several error messages.  Instead of 
  205.  
  206. plowing through your source code by hand, you can just refer to 
  207.  
  208. the latest listing, and go directly to the line number.  This way, 
  209.  
  210. you can see the whole routine where the error is, and what the 
  211.  
  212. full effects of that error are.
  213.  
  214.  
  215.      You can also go through all of your source code at one time 
  216.  
  217. tracking down the identifiers that are listed with the cross 
  218.  
  219. reference routine.  This way you can see where you messed up in 
  220.  
  221. your declarations, and make the corrections on your print out 
  222.  
  223. before going in with the editor to make the corrections.  
  224.  
  225.  
  226.      This method of tracking down identifiers is faster than 
  227.  
  228. plowing through with the editor trying to track down all the 
  229.  
  230. changes.  With all the corrections listed on your print out in the 
  231.  
  232. order that they happen, you can just go straight through the file, 
  233.  
  234. instead of jumping around from section to section.  You also won't 
  235.  
  236. have to worry about changing line counts, since you will be able 
  237.  
  238. to what lines are before and after your identifier.
  239.  
  240.  
  241.      When you have a print out from this routine, you can keep it 
  242.  
  243. current by having a few blank lines in your original source code.  
  244.  
  245. This way, when you do add a line, you can add it from one of blank 
  246.  
  247. lines.  Doing this will keep your line numbers valid for a longer 
  248.  
  249. length of time.  You can then easily track down your run-time 
  250.  
  251. errors, since your print out will still have valid line numbers 
  252.  
  253. for most of the code.
  254.  
  255.  
  256.      The box sequence for this routine is as follows:
  257.  
  258.      --GEM File Selector box.
  259.      --Start/End dialog box.
  260.  
  261.  
  262.      The Start-End dialog box will ask you for the line number or 
  263.  
  264. routine name that you want the listing to start at, and the line 
  265.  
  266. number or routine name that you want it to finish at.  When you 
  267.  
  268. are done entering this information, hit the "DONE" button to start 
  269.  
  270. the listing.
  271.  
  272.  
  273.      If you enter a blank line as the starting word, then the 
  274.  
  275. listing will start from the beginning of the file.  Entering a 
  276.  
  277. blank line as the ending word will cause the listing to continue 
  278.  
  279. to the end of the file.
  280.  
  281.  
  282.      If you enter a valid line number or routine name (One that 
  283.  
  284. actually exists.) there will be a short delay before the print out 
  285.  
  286. starts.  If you enter a line number that is larger than your 
  287.  
  288. program, or a routine name that does not exist, then it will read 
  289.  
  290. through the file looking for it, and will return you to the Main 
  291.  
  292. dialog box when it reaches the end of the file.
  293.  
  294.  
  295.      If you have entered a valid line number or routine name as 
  296.  
  297. the end word, the listing will stop printing when it reaches that 
  298.  
  299. line number or name.  If it doesn't find that line number or name, 
  300.  
  301. it will print all of the file from the starting point.
  302.  
  303.      
  304.      It should be noted that this program is set up for reasonable 
  305.  
  306. Pascal source code.  If you start having lines longer than 210 
  307.  
  308. characters, the last line won't be properly indented. (Just 
  309.  
  310. thought you'd like to know.)
  311.  
  312.  
  313.                          Showing files
  314.       ====================================================
  315.  
  316.      This routine acts almost exactly like the List routine. The 
  317.  
  318. differences are that it sends the display to the screen, and that 
  319.  
  320. it ignores the "END AT" option in the Start/End dialog box.
  321.  
  322.  
  323.      This routine is used to track down a starting and ending 
  324.  
  325. position for the other routines.  If you aren't sure of where you 
  326.  
  327. want to start a listing or a cross referencing, you can just start 
  328.  
  329. looking from the beginning of the file.  This way you can save 
  330.  
  331. time and paper when you list or cross reference your file. You can 
  332.  
  333. also save time in the cross reference routine by just referencing 
  334.  
  335. the routines you want.
  336.  
  337.  
  338.        For the details on using this routine, go to the List 
  339.  
  340. section of this article.  This routine will display the file to 
  341.  
  342. the screen 19 lines at a time.  At the bottom of each screen you 
  343.  
  344. will see the prompt "More?".   Entering in a "N", "n", or a 
  345.  
  346. CONTROL C, will abort the listing.  Any other key will show you 
  347.  
  348. the next page.
  349.  
  350.  
  351.       One thing to be noted again is that the "End at" prompt in 
  352.  
  353. the dialog box will be ignored.  You can go ahead and enter 
  354.  
  355. something, but it will be up to you to end the listing by a "N", 
  356.  
  357. "n", or a CONTROL C.
  358.  
  359.  
  360.                      Fixing Capitalization
  361.       ====================================================
  362.  
  363.      This routine goes through a file and fix the capitalization 
  364.  
  365. style on eight sets of words, with four options of capitalization 
  366.  
  367. for each word set.
  368.  
  369.  
  370.      You would use this when your file is already indented and 
  371.  
  372. formatted in a specific way, and you don't want to use the Format 
  373.  
  374. routine to reformat the program.
  375.  
  376.  
  377.      This routine is helpful for making the different types of 
  378.  
  379. words jump out of your listings.  For example, you can choose all 
  380.  
  381. the Pascal words to be converted into lower case, and your words 
  382.  
  383. to be in upper case.  This way, when you look at your listing, 
  384.  
  385. your identifiers will jump off the screen or listing at you.
  386.  
  387.  
  388.      The sequence for this routine is as follows:
  389.  
  390.      --GEM File Selector dialog box.
  391.  
  392.      --Pascal Reserved Words dialog box.
  393.      --Pascal Constants dialog box. 
  394.      --Pascal Types dialog box. 
  395.      --Pascal Routines dialog box. 
  396.      --GEM Routines dialog box. 
  397.      --GEM Types dialog box. 
  398.      --GEM Constants dialog box. 
  399.      --Your Words dialog box. 
  400.  
  401.  
  402.      Each of Word dialog boxes will have the name of the word set 
  403.  
  404. at the top, and then four buttons describing how you want that 
  405.  
  406. word set to be capitalized.  Hitting any of the buttons will end 
  407.  
  408. that dialog box, and move you to the next one.  
  409.  
  410.  
  411.      The routine will start after you have entered the capitaliz- 
  412.  
  413. ation option for Your Words.  The routine will read in your file, 
  414.  
  415. make the corrections, and then write it out to another file with a 
  416.  
  417. ".CAP" extension.
  418.  
  419.  
  420.      It should be noted here that if you are redefining a Pascal 
  421.  
  422. or GEM word, that it will still be capitalized as the original 
  423.  
  424. word type.  This routine isn't smart enough to pay attention to 
  425.  
  426. what words you have redefined.  
  427.  
  428.  
  429.      The high point of all of that is when you use this routine, 
  430.  
  431. the new listing will point out which words you have used that 
  432.  
  433. could have another meaning.  For example, define all your words to 
  434.  
  435. be in lower case, and all the other words to be something else.  
  436.  
  437. Any word that you use that is a GEM or Pascal word will be 
  438.  
  439. capitalized in something other that lower case.
  440.  
  441.  
  442.      The eight word sets are:
  443.      
  444.      --Pascal Reserved Words. (For, Do, Case, While, Repeat, etc.)
  445.  
  446.      --Pascal Constants. (True, False, Maxint, etc.)
  447.  
  448.      --Pascal Types. (Char, Text, Integer, String, etc.)
  449.  
  450.      --Pascal Routines. (Writeln, Reset, etc.)
  451.  
  452.      --GEM Routines. (Do_Dialog, Get_in_file, Draw_String, etc.)
  453.  
  454.      --GEM Types. ( Str255, Dialog_ptr, M_Bee, etc.)
  455.  
  456.      --GEM Constants. (Selected, None, Selectable, etc.)
  457.  
  458.      --Your Words. (Any words that you use that aren't inside of a 
  459.               comment or string, and aren't one of the above.  
  460.               That is, X, Y, Your_Choice are your words, but 
  461.               Writeln( even if you redeclare it), 'This is a 
  462.               literal', and {This is a comment.} aren't.)
  463.  
  464.  
  465.      The capitalization options are:
  466.  
  467.      --All Capitals.      (From Roger_Wilco to ROGER_WILCO.)
  468.                           (From ROGER_WilcO to ROGER_WILCO.)
  469.                           (From roger_wilco to ROGER_WILCO.)
  470.  
  471.      --All Lower Case.    (From Roger_Wilco to roger_wilco.)
  472.                           (From ROGER_WILCO to roger_wilco.)
  473.                           (From roger_wilco to roger_wilco.)
  474.  
  475.      --First Letter Caps. (From Roger_Wilco to Roger_Wilco.)
  476.                           (From ROGER_WILCO to Roger_Wilco.)
  477.                           (From Roger_wilcO to Roger_Wilco.)
  478.  
  479.      --Original.          (From Roger_Wilco to Roger_Wilco.)
  480.                           (From RoGER_WilcO to RoGER_WilcO.)
  481.                           (From roger_wilco to roger_wilco.)
  482.  
  483.  
  484.                  Cross Referencing Identifiers
  485.       ====================================================
  486.  
  487.      The Cross Reference routine goes through your source code, 
  488.  
  489. and creates a text file telling you about your variables.  The 
  490.  
  491. SHORT form, which is best for saving storage space creates a 
  492.  
  493. sorted list of each identifier, where it was used, and a one 
  494.  
  495. letter descriptor of that use. The FULL form lists out the the 
  496.  
  497. file on a line by line description of which identifiers you are 
  498.  
  499. using and where they were declared. 
  500.  
  501.  
  502.      A good Cross Reference routine can save hours, if not days 
  503.  
  504. of trouble shooting, as well as save a few K here and there.  I'd 
  505.  
  506. rather not think about the times that I've accidentally messed 
  507.  
  508. everything up by using a global variable and thinking that it was 
  509.  
  510. local instead.  You can also easily track down every occurrence of 
  511.  
  512. a variable to see where it's being changed, and which one of those 
  513.  
  514. changes is the one that's messing your program up.
  515.  
  516.  
  517.      You can also see which identifiers are being used only once, 
  518.  
  519. and you can delete them from your source code, or use them. (As 
  520.  
  521. you see fit.)
  522.  
  523.  
  524.      This routine also comes in handy if you like to steal/salvage 
  525.  
  526. /re-use code from other programs.  If you tend to import the 
  527.  
  528. majority of a routine, and all of it's declarations, this will 
  529.  
  530. come in handy.  After you have imported and modified the code, 
  531.  
  532. there are almost always some identifiers declared, but not used in 
  533.  
  534. the routine.  
  535.  
  536.  
  537.      Instead of going through it by hand, you can just run it 
  538.  
  539. through this routine.  Everytime an identifier is declared, it 
  540.  
  541. starts a new line in the print out.  So, just by looking at the 
  542.  
  543. print out, your unused identifiers will jump off the page at you.  
  544.  
  545. Then you can go and delete them from your source code file.
  546.  
  547.  
  548.      An example of this is as follows:
  549.  
  550.  
  551. 1)          Word   1234:V1   1241=v1   1243:v1
  552. 2)                 1276:V1
  553. 3)                 1350:V1   1360=v1
  554.  
  555.  
  556.      We have declared "Word" on lines 1234, 1276, and 1350 of the 
  557.  
  558. program.  But, it appears that it is never being used in the 
  559.  
  560. routine that includes line 1276.  This situation is definitely 
  561.  
  562. worth looking into.  It's very possible that you could delete that 
  563.  
  564. declaration without causing any harm to the program at all.
  565.  
  566.  
  567.      Another thing to note about the above sample is lines 1350 
  568.  
  569. and 1360.  You have it declared at 1350, and modified at 1360. 
  570.  
  571. (The = sign shows us that it's being modified.)  Now why would we 
  572.  
  573. want to just set a variable to something and never use it's value?  
  574.  
  575. It's probable that you're just initializing it to some value and 
  576.  
  577. never using it.  (A common waste of time and space.)  This is 
  578.  
  579. something that possibly could be deleted from the program.
  580.  
  581.  
  582.      Another good use is for when you have nested routines.  If 
  583.  
  584. you declared an identifier in your main routine and then declare 
  585.  
  586. it again in a sub-routine, this routine will point that out to 
  587.  
  588. you.  That's because everytime you declare an identifier, it 
  589.  
  590. starts a new line in the file.  So what happens is you will see 
  591.  
  592. the identifier listed once as declared, and then a new line, with 
  593.  
  594. it listed as declared again.  It will look something like this:
  595.  
  596.  
  597. 1)          Word   1234:V1   1241:v1   1243:v1
  598. 2)                 1276:V1
  599. 3)                 1280:V2   1283:v2   1296:v2   1301:v2
  600. 4)                 1350:v1   1360:v1
  601.  
  602.  
  603.      Where line 1 above is a normal use of the variable.  Line 2 
  604.  
  605. is another declaration of the variable.  In line 3 we have it 
  606.  
  607. declared and used in a nested routine.  Line 4 is where we start 
  608.  
  609. using the variable we declared on line 2.  In this instance, you 
  610.  
  611. would go and look at those lines to see if you really need to have 
  612.  
  613. it declared again.  True, the program may run just as well if it's 
  614.  
  615. redeclared, but it's not as nice.
  616.  
  617.  
  618.      The sequence for this routine is as follows:
  619.  
  620.      --GEM File Selector dialog box.
  621.  
  622.      --Start/End dialog box.
  623.      --Cross Reference Mode alert box.
  624.      --Routines Only alert box.
  625.      --Reference Include Files alert box.
  626.  
  627.      The Start/End dialog box is here to determine which sections 
  628.  
  629. of code should be cross referenced.  This box follows the same 
  630.  
  631. general rules as listed in the Listing section.  The routine will 
  632.  
  633. go through your program keeping track of which identifiers are 
  634.  
  635. declared where, but will only create the file when it reaches the 
  636.  
  637. start position.  You would use this when you want to cross 
  638.  
  639. reference certain sections of your program.
  640.  
  641.  
  642.      The Cross Reference Mode alert box is to determine whether 
  643.  
  644. you want the FULL or SHORT Cross Reference modes.  The SHORT Mode 
  645.  
  646. will just print out the name of the identifier, the line number 
  647.  
  648. that it is on, a one character identifier description, and the 
  649.  
  650. level that it is being used.
  651.  
  652.  
  653.     The FULL Mode of the Cross Reference utility shows the above 
  654.  
  655. information, but is preceded by a line by line use of the varia- 
  656.  
  657. bles.  In this case, it goes routine by routine, listing in order 
  658.  
  659. where you declared and where you used certain identifiers.  This 
  660.  
  661. comes in really handy for making sure that you are only using 
  662.  
  663. global identifiers where you should be.
  664.  
  665.  
  666.      The Routines Only alert box is for when you just want to 
  667.  
  668. track down where your routines are declared and used.  It gives 
  669.  
  670. almost the same output as cross referencing all your identifiers, 
  671.  
  672. except that it will only print out your routine information.
  673.  
  674.  
  675.      The Reference Include Files alert box is so you can Cross 
  676.  
  677. Reference the INCLUDE files that your programs uses.  If you 
  678.  
  679. choose this option, everytime the program finds an INCLUDE file 
  680.  
  681. declared, it will pause the program and ask you to locate the 
  682.  
  683. Include file.  If you enter a valid file name, the Cross 
  684.  
  685. Referencer will open that file and cross reference it as well.  It 
  686.  
  687. will start a new line number everytime it includes another file, 
  688.  
  689. and will return to the old line number when it resumes Cross 
  690.  
  691. Referencing the main program file.  (It should be stated that the 
  692.  
  693. program will only recognize a "{$I" command when it is the first 
  694.  
  695. three characters on the line.)
  696.  
  697.  
  698.      The Used/Modified characters are as follows:
  699.  
  700.      --':'  This variable is being used or accessed.
  701.  
  702.      --'='  This variable is being modified on this line.
  703.  
  704.  
  705.      The one letter characters are as follows:
  706.  
  707.  
  708.      --C: This identifier was declared as a constant.
  709.  
  710.      --T: This identifier was declared as a type.
  711.  
  712.      --F: This function was declared on this line.
  713.  
  714.      --f: This function was called on this line.
  715.  
  716.      --P: This procedure was declared on this line.
  717.  
  718.      --p: This procedure was called on this line.
  719.  
  720.      --G: This Global identifier was declared on this line.
  721.  
  722.      --g: This global identifier was used on this line.
  723.  
  724.      --V: This identifier was declared locally on this line.
  725.  
  726.      --v: This identifier was used locally on this line.
  727.  
  728.      --R: The procedure was called recursively from itself on this 
  729.          line.
  730.  
  731.      --?: You haven't declared it yet.
  732.  
  733.  
  734.      A couple of notes on the current version.
  735.  
  736.      --It is set up for a maximum of 1000 global identifiers.
  737.      --This version will only work to four levels of nested 
  738.           routines, not counting the global level.
  739.      --All routines are stored in their own area of memory, and 
  740.           are treated as if they were declared globally.
  741.  
  742.                  Formatting Pascal Source code
  743.       ====================================================
  744.  
  745.      Well, this is the tricky part of the program.  This routine 
  746.  
  747. will take your Pascal source code, and format it (or pretty print, 
  748.  
  749. if you prefer that term) for you.  This is probably one of the 
  750.  
  751. best things you can do for your source code since it becomes much 
  752.  
  753. more readable.  And when it's easily readable, it's easily 
  754.  
  755. fixable and changeable.
  756.  
  757.      
  758.      When you have formatted code, tracking down bugs becomes much 
  759.  
  760. easier than tracking them down in "Messy" looking code.  It also 
  761.  
  762. just looks nicer too.  It's sort of like a car.  Doesn't it feel 
  763.  
  764. better to drive a car when it's clean, rather than when it's 
  765.  
  766. dirty?  It's the same way with source code.  Clean looking code is 
  767.  
  768. just so much easier to work with than sloppy code.  
  769.  
  770.  
  771.      The way I  and many others write code, is just plain messy.  
  772.  
  773. I'm always in too much of a hurry to really bother with writing 
  774.  
  775. clean code the first time through it.  I'd much rather write it, 
  776.  
  777. than make it look nice.  I never get the BEGIN/END pairs lined up 
  778.  
  779. correctly, my IF/THEN/ELSE statements are always ugly looking, and 
  780.  
  781. my capitalization is NEVER consistent.  I take my car to the 
  782.  
  783. car wash, and now I can do the same thing with my programs.  And 
  784.  
  785. the end result is code that's a lot nicer to work on.
  786.  
  787.  
  788.      "Well", you ask, "What else is pretty code good for?"  A lot, 
  789.  
  790. it turns out.  Nice looking code that follows the same format 
  791.  
  792. rules throughout is a lot easier to debug and modify than sloppy 
  793.  
  794. code, or code that isn't indented consistently.  With formatted 
  795.  
  796. code, you can make sure that statements are on the correct side of 
  797.  
  798. your BEGIN statements or your END statements.  It will also 
  799.  
  800. visually show you which routines are nested, as well as what 
  801.  
  802. routines they are nested in.  Formatted code can also make complex 
  803.  
  804. IF/THEN/ELSE statements extremely clear. 
  805.  
  806.  
  807.      The sequence for this routine is as follows:
  808.  
  809.      --GEM File Selector dialog box.
  810.  
  811.      --Defaults alert box.
  812.      --Print or Compile alert box.
  813.  
  814.      --Tabbing dialog box.
  815.  
  816.           Capitalization dialog boxes.
  817.      --Pascal Reserved Words dialog box.
  818.      --Pascal Constants dialog box. 
  819.      --Pascal Types dialog box. 
  820.      --Pascal Routines dialog box. 
  821.      --GEM Routines dialog box. 
  822.      --GEM Types dialog box. 
  823.      --GEM Constants dialog box. 
  824.      --Your Words dialog box. 
  825.  
  826.      --Returns dialog box #1.
  827.      --Returns dialog box #2.
  828.  
  829.  
  830.      After you've picked the file you want formatted, the program 
  831.  
  832. will ask you if you want to accept the default values or not. 
  833.  
  834. (These are listed in appendix 1.)  If you don't choose the default 
  835.  
  836. option, then you will go through a series of alert and dialog 
  837.  
  838. boxes where you can pick out your own particular formatting rules.
  839.  
  840.  
  841.      After you choose whether or not to accept the defaults, you 
  842.  
  843. will move on to the Print/Compile alert box.  If you choose the 
  844.  
  845. Print option, your source code will be formatted for the printer.  
  846.  
  847. The file extension for the Print option is ".PRN" and for the 
  848.  
  849. compile option it is ".FRM".
  850.  
  851.  
  852.      The Compile option will format your code according to your 
  853.  
  854. rules, the same as the Print option.  But for lines that are longer 
  855.  
  856. than 80 columns, it will slide those left to column one.  If they 
  857.  
  858. are still longer than 80 columns, the line number will be printed 
  859.  
  860. to an ".ERR" file, so you can look at them next time you use the 
  861.  
  862. editor.
  863.  
  864.  
  865.      What the Print Option does is insert a "|" between your 
  866.  
  867. BEGIN/END sets and your REPEAT/UNTIL sets.  Also, a "*" will be 
  868.  
  869. printed in front of your nested routines to point them out.  And 
  870.  
  871. lastly, each line will be printed with ALL of the proper 
  872.  
  873. indentations, instead of having lines longer than 80 columns slid 
  874.  
  875. over to the left as is done with the Compile option.  
  876.  
  877.  
  878.      If you've decided to set up your own rules for indentation, 
  879.  
  880. carriage returns, and capitalization, you'll move on to those 
  881.  
  882. dialog boxes.  If you haven't, (you've accepted the defaults) then 
  883.  
  884. the program will start formatting your code.
  885.  
  886.  
  887.          The first dialog box you will come to is the indents or 
  888.  
  889. Tabbing dialog box.  This is where you choose how many blanks you 
  890.  
  891. want in front of each line.  This is only set up for a maximum of 
  892.  
  893. 256 indents.  Any more than that, and your on your own.  Of 
  894.  
  895. course, 256 indents, at 1 space each is 256 characters, so your in 
  896.  
  897. deep trouble anyways.
  898.  
  899.  
  900.      The next series of dialog boxes are the Capitalization 
  901.  
  902. options.  These are the same boxes that are described in the 
  903.  
  904. Capitalization routine.  Instead of repeating myself again for a 
  905.  
  906. few pages, I'll just refer you back to that section for the 
  907.  
  908. details on them.
  909.  
  910.  
  911.      After the Capitalization options comes the two Return dialog 
  912.  
  913. boxes.  Each box has five options, with a YES and a NO button for 
  914.  
  915. each.  Actually, only the first one deals with returns.  The other 
  916.  
  917. is general program clean up.  These two boxes are where you can 
  918.  
  919. either add, or clean up a lot of garbage to your program.  I'll 
  920.  
  921. discuss how each option can be misused as it's described.  
  922.  
  923.  
  924.      The first box deals specifically with adding Returns.  The 
  925.  
  926. first option is whether or not to add a Return after each Label, 
  927.  
  928. Const, Type, and Var statement.  If you say no, then the first 
  929.  
  930. identifier after each declaration will be on the same line as the 
  931.  
  932. declaration.  If you say yes, then there will be a Return after 
  933.  
  934. each statement.  Doing this will make your routine declarations 
  935.  
  936. more spread out, and a little easier to read.
  937.  
  938.  
  939.      The next two options deal with Returns before and after 
  940.  
  941. commas.  Some people like a Return before their commas, some like 
  942.  
  943. it after their commas.  If you choose both (Yes and Yes) then 
  944.  
  945. every comma in your program will be on it's own line.  This winds 
  946.  
  947. up looking silly.  If you want to leave your Comma-Returns the way 
  948.  
  949. they are, enter a No for both of them, and a Yes for the "Preserve 
  950.  
  951. Comma Returns in the next dialog box.
  952.  
  953.  
  954.       The next two options deal with Returns before and after 
  955.  
  956. AND and OR statements.  Some people like a Return before their 
  957.  
  958. AND's, some like Returns before their OR's.  If you choose both 
  959.  
  960. (Yes and Yes) then every AND and OR in your program will be 
  961.  
  962. started on it's own line.  
  963.  
  964.  
  965.      It's a good idea to have at least one of the options as a 
  966.  
  967. yes.  If you say No to both options, then you have decided to get 
  968.  
  969. some VERY long lines in your program.  What will happen is that 
  970.  
  971. the program will keep putting them all on one line until it 
  972.  
  973. reaches the DO, THEN or ELSE statement, or it reaches 255 
  974.  
  975. characters.  (At this point, it stops formatting, and tells you 
  976.  
  977. that you've made a mistake.  Look up the .ERR file to find out 
  978.  
  979. where.)
  980.  
  981.  
  982.      The second dialog box deals with general housecleaning in 
  983.  
  984. your program.  The first option is whether or not you want to 
  985.  
  986. preserve your existing Comma-Returns.  (That is, a comma, 
  987.  
  988. immediately followed by a Return.)  
  989.  
  990.  
  991.      Choosing Yes is usually a good idea here.  This way, you'll 
  992.  
  993. keep your routine calls and your identifier declarations spread 
  994.  
  995. out.  If you choose No, then the routine will follow your rules 
  996.  
  997. for Comma Returns from the previous dialog box.  If you choose No 
  998.  
  999. for this option, and No for the two comma options above, you'll 
  1000.  
  1001. get all of your identifiers on one line.  Which may or may not be 
  1002.  
  1003. what you want.  You have been warned.
  1004.  
  1005.  
  1006.      The second option is whether or not you want the program to 
  1007.  
  1008. strip all the blank lines from your program.  In this case, a 
  1009.  
  1010. blank line is one that is either just a Return, or spaces and a 
  1011.  
  1012. Return.  
  1013.  
  1014.  
  1015.      The third option in the box is to determine if you want to 
  1016.  
  1017. preserve your Math Return statements. ( '+', '-', '*', '/' or '=' 
  1018.  
  1019. followed by a RETURN.)  If you say Yes, then the formatter will 
  1020.  
  1021. keep each of those Returns in your program.  If you say no, then 
  1022.  
  1023. the formatter will possibly give you some very long math formulas. 
  1024.  
  1025. (Which you shouldn't have in the first place!)
  1026.  
  1027.  
  1028.      The fourth option is whether or not you want the program to 
  1029.  
  1030. add a Return before each BEGIN statement.  If you say Yes, then 
  1031.  
  1032. every BEGIN will be on it's own line.  If you say No, then the 
  1033.  
  1034. only time a BEGIN will have a Return before it is when it follows 
  1035.  
  1036. a semicolon.
  1037.  
  1038.  
  1039.      The last option is whether or not you want the program to add 
  1040.  
  1041. a Form Feed (Control L) before each routine.  This is mainly for 
  1042.  
  1043. when you will be printing out the file directly, and want each 
  1044.  
  1045. routine on it's own page.
  1046.  
  1047.  
  1048.      While the code is being formatted, there are certain rules 
  1049.  
  1050. that will be followed for adding spaces and Returns inside your 
  1051.  
  1052. program.  Certain characters (",", "(", ")" and others), and 
  1053.  
  1054. certain character sets ("BEGIN", "END", ":=", "<=", and others) 
  1055.  
  1056. will have certain spacing and return rules enforced on them.  
  1057.  
  1058.  
  1059.  
  1060.                          Procedure I/O
  1061.       ====================================================
  1062.       
  1063.  
  1064.      This routine will go through your source code and create a 
  1065.  
  1066. file of all the routines, and their parameters.  
  1067.  
  1068.  
  1069.      With this listing you will have a handy table of which 
  1070.  
  1071. parameters are and aren't variable, their order, and the order in 
  1072.  
  1073. which you have declared your routines.  This is useful when 
  1074.  
  1075. calling a routine and you aren't sure of what the parameters are, 
  1076.  
  1077. you can just look at your printout, instead of searching for the 
  1078.  
  1079. declaration with your editor.  This is also useful when you are 
  1080.  
  1081. trying to convert string value parameters into variable 
  1082.  
  1083. parameters.  It will show you exactly where you need to make 
  1084.  
  1085. changes. (Strings take forever to pass as values!)
  1086.  
  1087.  
  1088.      The only dialog box in this routine is the GEM file selector 
  1089.  
  1090. box.  The resulting file will have a ".PRO" extension. 
  1091.  
  1092.  
  1093.                            Statistics
  1094.       ====================================================
  1095.  
  1096.  
  1097.      This routine will go through your source code and write out 
  1098.  
  1099. each occurrence of any word that you tell it to find.  
  1100.  
  1101.  
  1102.      The first routine is mainly for tracking down where you use 
  1103.  
  1104. certain Pascal or GEM words.  This would be mainly for looking for 
  1105.  
  1106. sections that might be improved by making them into a routine.  
  1107.  
  1108. For instance, you might want to track down all of your RESET 
  1109.  
  1110. statements to see if they are similar enough to warrant being made 
  1111.  
  1112. into a routine.  With this routine, it's no problem to get a 
  1113.  
  1114. quick listing of all the occurrences.
  1115.  
  1116.  
  1117.      --GEM file selector box.
  1118.      --Look for what word dialog box.
  1119.  
  1120.      
  1121.      The Word Find routine will ask you for a word.  It will then 
  1122.  
  1123. go through your file looking for that word.  Everytime that word 
  1124.  
  1125. is located, it will write out the line number of the occurrence to 
  1126.  
  1127. a file with a ".WRD" extender.
  1128.  
  1129.  
  1130.  
  1131.                             Leaving
  1132.       ====================================================
  1133.  
  1134.      This is the easiest part of the whole program.  Among the 
  1135.  
  1136. options you see at the Main dialog box, you will see the "QUIT" 
  1137.  
  1138. button.  Just click the mouse in there, and away you go, straight 
  1139.  
  1140. back to the desktop.  Fun, Huh?
  1141.  
  1142.  
  1143.                          Technical Info
  1144.       ====================================================
  1145.  
  1146.                   General Program Information
  1147.  
  1148.      I started working on the program last summer, (July 19, 1986) 
  1149.  
  1150. and I've been working on it ever since.  Now I know this sounds 
  1151.  
  1152. like a long time, mainly because it is.  However, it just started 
  1153.  
  1154. out as a formatter for my programs.  As I wrote or imported 
  1155.  
  1156. routines for the formatter, I started adding other goodies to it.  
  1157.  
  1158. The most notable is the cross reference function.  (I mean, hey, I 
  1159.  
  1160. already had most of the subroutines I would need so why not?)  
  1161.  
  1162. And things were added here and there as I discussed the program 
  1163.  
  1164. with other people.  Overall, I've probably between 500 and 600 
  1165.  
  1166. hours writing and debugging.  
  1167.  
  1168.  
  1169.      In writing this program I've also discovered several errors 
  1170.  
  1171. in OSS Pascal.  The first main error was with the way Version 1.00 
  1172.  
  1173. of the compiler handled large arrays of information.  This turned 
  1174.  
  1175. out to be a real pain to track down and I finally wound up calling 
  1176.  
  1177. OSS about it.  It turns out that the early versions of the 
  1178.  
  1179. compiler would randomly eat the contents of large arrays.  So I 
  1180.  
  1181. was losing the contents of my reserved word list.  This was fixed 
  1182.  
  1183. in later releases, but if you try to compile the program under an 
  1184.  
  1185. early release, you might have problems.  (So call up OSS and get 
  1186.  
  1187. the upgrade.)
  1188.  
  1189.  
  1190.      I also discovered a problem with the linker.  I'm not sure 
  1191.  
  1192. why, but it seems that when you have a large number of routines in 
  1193.  
  1194. a module the linker flips out.  In my particular case, a set of 
  1195.  
  1196. routines in the module were not returning any valid values from 
  1197.  
  1198. the routine.  It was as if the whole routine was just a BEGIN/END 
  1199.  
  1200. statement without any code between them.  This was solved by 
  1201.  
  1202. putting the offending routines back into the main program file.
  1203.  
  1204.  
  1205.      It also turns out that the manual doesn't give any details on 
  1206.  
  1207. how to call a dialog box without any editable fields.  The call 
  1208.  
  1209. requires you to pass a pointer to the editable field.  If you pass 
  1210.  
  1211. it a pointer to button or display line, it bombs the program.  
  1212.  
  1213. After posting several notices on assorted boards, I finally got 
  1214.  
  1215. the answer.  It turns out you just have to pass it a 0 (zero) as 
  1216.  
  1217. the editable field parameter.
  1218.  
  1219.  
  1220.                      Data File Information
  1221.  
  1222.  
  1223.      The Data file (EPASUTIL.DAT) is a simple text file.  The 
  1224.  
  1225. first half of the file is the word list for the program.  These 
  1226.  
  1227. are the various Pascal and GEM words that OSS Pascal uses.  I 
  1228.  
  1229. obtained the various GEM and Pascal words out of the various 
  1230.  
  1231. Pascal include files and the manual.  Each word set consists of a 
  1232.  
  1233. single digit, a Return, the word, and another Return.  The digit 
  1234.  
  1235. describes what kind of word follows.  (See appendix 2.) 
  1236.  
  1237.  
  1238.      The second half of the program are the contents of assorted 
  1239.  
  1240. alert boxes.  These are read into two arrays PFILEERR (Pascal  
  1241.  
  1242. error) and TFILEERR (TOS error).  When an error occurs, I just 
  1243.  
  1244. use the error number as the index for the appropriate array.
  1245.  
  1246.  
  1247.                         Support Modules
  1248.  
  1249.  
  1250.      The assorted "Fast Read" routines were written because they 
  1251.  
  1252. increased the speed of the assorted READLNS by a factor of 9 to 12 
  1253.  
  1254. times.  Basically all these routines do is load a one dimension 
  1255.  
  1256. array of characters straight off the disk, and then go through the 
  1257.  
  1258. array sending off a line of text everytime it finds a Return or 
  1259.  
  1260. the end of the file.
  1261.  
  1262.  
  1263.      The Next_Word routine takes a list of parameters including a 
  1264.  
  1265. starting position and a starting condition and returns the next 
  1266.  
  1267. word in a text line.  Basically anything that Pascal accepts as a 
  1268.  
  1269. word, this routine will return.  It's also smart enough so that it 
  1270.  
  1271. will skip over words that are enclosed by comments or single 
  1272.  
  1273. quotes.  If if finds a comment that doesn't end on that line, it 
  1274.  
  1275. returns a null word to the calling routine and lets the calling 
  1276.  
  1277. routine know what kind of comment or literal caused the exit.
  1278.  
  1279.  
  1280.      In_List takes a word parameter and performs a binary search 
  1281.  
  1282. through the List array looking for it.  For those of you who 
  1283.  
  1284. aren't familiar with a binary search, it's similar to the game 
  1285.  
  1286. "Twenty Questions."  It first looks in the middle of the list to 
  1287.  
  1288. see if that word is greater than, less than or equal to the word 
  1289.  
  1290. we're looking for.  If it's greater than the word we're looking 
  1291.  
  1292. for, it looks in the middle of the lower half,  If it's less than 
  1293.  
  1294. than the word we're looking for, it looks in the middle of the 
  1295.  
  1296. upper half.  It continues doing this until it finds the word or 
  1297.  
  1298. determines that it isn't in the list at all.
  1299.  
  1300.  
  1301.      The Is_Cancel function simply determines if the user is  
  1302.  
  1303. holding down the Control C key down when the function is called.  
  1304.  
  1305. This is being used so the you can abort out of a routine if you 
  1306.  
  1307. want to.
  1308.  
  1309.  
  1310.      Advance_File_Pointer goes through an already opened file 
  1311.  
  1312. looking for a certain line number or routine name.  When it finds 
  1313.  
  1314. it, it returns that text line and the line number to the calling 
  1315.  
  1316. routine.  This is called from the List and Show routines.
  1317.  
  1318.  
  1319.  
  1320.                               Init
  1321.  
  1322.      This routine is located in the module section.  All it does 
  1323.  
  1324. is set up all the dialog and alert boxes, load the data file, and 
  1325.  
  1326. show the title screen.  Most of the dialog box routines were 
  1327.  
  1328. copied and modified from one dialog box routine I stole from 
  1329.  
  1330. another one of my programs.
  1331.  
  1332.  
  1333.                              Format
  1334.  
  1335.      OK, I know this is the one routine that you all want to know 
  1336.  
  1337. how it works.  Get ready then.  First it sets up all the relevant 
  1338.  
  1339. variables in Format_Init.  It then calls Format_Stats which goes 
  1340.  
  1341. through the assorted dialog and alert boxes to get the users 
  1342.  
  1343. preferences for the program format.  It might interest you that 
  1344.  
  1345. the two Returns dialog boxes are the same dialog box with the text 
  1346.  
  1347. changed.  This is detailed in the Get_Returns routine.
  1348.  
  1349.  
  1350.      The program then opens up three files, the input file, the 
  1351.  
  1352. output file, and an error file.  It then goes into a WHILE NOT EOF 
  1353.  
  1354. loop to get and process each of the lines in the input file.
  1355.  
  1356.  
  1357.      After it gets the line it passes the line to Fix_Line and 
  1358.  
  1359. then to Key_Words.  Fix_Line is the first pass of the formatter 
  1360.  
  1361. for each line.  It's first job is to strip all of the extra spaces 
  1362.  
  1363. from the line (Leading, trailing and inside the line.)  It also 
  1364.  
  1365. adds a Return and a Line Feed after each "Live" semicolon. (One 
  1366.  
  1367. that's not in a literal or a comment.)  It also adds spaces 
  1368.  
  1369. between certain characters to "Prettify" the line.  And lastly, on 
  1370.  
  1371. it's way out of Fix_Line, it checks to see if the line ends as a 
  1372.  
  1373. comment or literal.  If it is, then it adds another Return and a 
  1374.  
  1375. Line Feed at the end of the line.  If the line ends as an 
  1376.  
  1377. unfinished comment, it tacks on a closing comment before the 
  1378.  
  1379. Return and an open comment after the Return.
  1380.  
  1381.  
  1382.      Key_Words is where most of the Returns are added, and the 
  1383.  
  1384. capitalization is fixed.  It takes the line and goes through it 
  1385.  
  1386. using the Next_Word procedure.  Everytime it gets a word the 
  1387.  
  1388. routine does two things.  First it checks if it's a special word 
  1389.  
  1390. that might need a Return.  If it is, then it adds a Return before 
  1391.  
  1392. or after it, according to the program's and the user's rules.  It 
  1393.  
  1394. then calls Change_Word where the word has it's capitalization set 
  1395.  
  1396. according to the rules in the Caps array.
  1397.  
  1398.  
  1399.      Then if the length of that line and the line in Prior_Line 
  1400.  
  1401. are less than 255 it will hit the second half of the formatter.  
  1402.  
  1403. What happens now is that Prior_Line and the current line are 
  1404.  
  1405. concatenated together.  It then goes through Prior_Line extracting 
  1406.  
  1407. each line that is terminated by a Return.  (This may leave some 
  1408.  
  1409. characters in Prior_Line when we leave this section.  They'll just 
  1410.  
  1411. get put onto the start of the next line.)  As each line is 
  1412.  
  1413. extracted, it gets passed to the Add_Tabs routine.
  1414.  
  1415.  
  1416.      The Add_Tabs routine takes each line and adds the leading 
  1417.  
  1418. blanks to it.  While it's doing this, it scans the line to see if 
  1419.  
  1420. there are any tabbing modifier words in it.  (BEGIN, END, REPEAT, 
  1421.  
  1422. CASE, etc.)  If it finds a word that would cause the tabbing to be 
  1423.  
  1424. increased (BEGIN, CASE, DO, etc.) it adds the blanks to the line 
  1425.  
  1426. and then adds that word to the tab stack (Tabbing).  If it finds a 
  1427.  
  1428. word that would cause the tabbing to be decreased (END, UNTIL, 
  1429.  
  1430. BIOS, etc.) takes that word from the tab stack and then it adds 
  1431.  
  1432. the blanks to the line.
  1433.  
  1434.  
  1435.      When it's all done with that, it goes back to the top of the 
  1436.  
  1437. loop and does the whole cycle again.
  1438.  
  1439.  
  1440.  
  1441.  
  1442.                         Cross Reference
  1443.  
  1444.  
  1445.      There were several general problems in writing this routine.  
  1446.  
  1447. the worst of them was that Pascal is a routine and level oriented 
  1448.  
  1449. language.  That is, every new or nested procedure creates a new 
  1450.  
  1451. list of identifiers that will be ignored when the procedure is 
  1452.  
  1453. done being executed.  And each nested routine can use all of the 
  1454.  
  1455. identifiers declared before it.  
  1456.  
  1457.  
  1458.      So I had to figure out how to store and then forget each of 
  1459.  
  1460. these identifiers when I was done using them.  I finally wound up 
  1461.  
  1462. implementing an array to hold all of the global words, and then a 
  1463.  
  1464. two dimensional array to hold all of the identifiers from each 
  1465.  
  1466. routine.  Whenever the program hits the final end in a routine, 
  1467.  
  1468. the program then resets the number of words know for that routine 
  1469.  
  1470. to zero, and then decrements the level counter by one.  Whenever a 
  1471.  
  1472. new routine is declared, it increments the level counter by one, 
  1473.  
  1474. and stores each of the identifiers into that level of the 
  1475.  
  1476. identifier array.
  1477.  
  1478.  
  1479.      The Add_to_Tree routine takes the word and it's line number 
  1480.  
  1481. and adds it to the binary tree.  If it's a new word it calls 
  1482.  
  1483. Make_Node.  If it's a word that is already in the tree, it calls 
  1484.  
  1485. Make_List_Node and adds it to the end of the linked list for that 
  1486.  
  1487. word.  I'm using a set of linked list connected to a binary tree 
  1488.  
  1489. mainly to save space.  If I wasn't doing it this way, the memory 
  1490.  
  1491. requirements become horrendous.  (I know, I did it that way first, 
  1492.  
  1493. but kept blowing the stack from recursion when I used it on this 
  1494.  
  1495. program.)
  1496.  
  1497.  
  1498.      The Make_Node routine creates a new node for the binary tree.  
  1499.  
  1500. In doing so it calls Make_List_Node which creates the first node 
  1501.  
  1502. for the linked list that is attached to each node in the tree.
  1503.  
  1504.  
  1505.      The Write_Tree procedure goes through the binary tree the 
  1506.  
  1507. program has constructed doing an in-order traversal of each node.  
  1508.  
  1509. At each node, it prints out the contents of the attached list 
  1510.  
  1511. going from the First_Node to the Last_Node.  
  1512.  
  1513.  
  1514.      Everytime a new declaration occurs, or six line numbers have 
  1515.  
  1516. been printed, the routine prints a carriage return to move down to 
  1517.  
  1518. the next line.  I could have just kept printing out the line 
  1519.  
  1520. numbers, but this way the resulting printout looks much nicer.
  1521.  
  1522.  
  1523.                              Lines
  1524.  
  1525.      This is just another interpretation of a line number printer.  
  1526.  
  1527. It looks for the starting position in the file (With 
  1528.  
  1529. Advance_File_Pointer) and the prints out each line with the 
  1530.  
  1531. corresponding line number.  Before it prints each line it checks 
  1532.  
  1533. the line for a Form Feed character.  If it finds one, it advances 
  1534.  
  1535. the page, prints a new page header, and clears the Form Feed 
  1536.  
  1537. character from the line.  Also, as it prints each line, it checks 
  1538.  
  1539. each line with Should_It_Be_Off to see if that line is the final 
  1540.  
  1541. line to be printed.
  1542.  
  1543.                               Show
  1544.  
  1545.      This routine was added after someone suggested that it might 
  1546.  
  1547. be handy to be able to look through a file to determine a starting 
  1548.  
  1549. point(s) for a listing or a cross referencing of a file.  
  1550.  
  1551. Basically it's similar to print routine except that it uses a 
  1552.  
  1553. Draw_String to put it on the screen.  
  1554.  
  1555.  
  1556.      Since the program is designed for program code, I didn't have 
  1557.  
  1558. to worry about lines longer that 160 columns.  Instead, the 
  1559.  
  1560. Put_It_On_The_Screen routine just breaks the line at column 76 and 
  1561.  
  1562. draws the remainder below it.  It doesn't worry about word 
  1563.  
  1564. wrapping since that would alter the number of blanks in a line.  
  1565.  
  1566. (Not a good thing when the number of blanks in a line is 
  1567.  
  1568. important.)
  1569.  
  1570.  
  1571.                          Procedure I/O
  1572.  
  1573.      This routine was initially suggested by one of the people in 
  1574.  
  1575. the BIX Atari.ST/Pascal conference.  It goes through the file 
  1576.  
  1577. looking for the words PROGRAM, PROCEDURE, and FUNCTION.  When it 
  1578.  
  1579. finds one of these words,  It then checks to see if the line has 
  1580.  
  1581. an Open Parenthesis character.  If it doesn't find one, it prints 
  1582.  
  1583. out that line. (No parameter list is there.)  If it does find an 
  1584.  
  1585. Open Parenthesis, it prints out that line and every following line 
  1586.  
  1587. until it finds a Close Parenthesis character.
  1588.  
  1589.  
  1590.      If All_Declarations is set to TRUE, then it keeps reading and 
  1591.  
  1592. printing lines until it finds the word BEGIN on a line.  At that 
  1593.  
  1594. point, it stops printing the lines and resumes the search for 
  1595.  
  1596. routine declarations.
  1597.  
  1598.  
  1599.                             Do_Caps
  1600.  
  1601.      This was one of the easier routines for me to write.  It's 
  1602.  
  1603. just a butchered version of the Do_Format routine that includes 
  1604.  
  1605. only the areas needed to change the word capitalization in a file.
  1606.  
  1607.  
  1608.                            Word_Find
  1609.  
  1610.      This is another of the routines that I added after I had 
  1611.  
  1612. written most of the support routines for it already.  I decided 
  1613.  
  1614. that since I already had the Next_Word routine written, I could 
  1615.  
  1616. use it to search through a file for any particular word and it's 
  1617.  
  1618. line number.  
  1619.  
  1620.  
  1621.      This routine just goes through a text file line by line 
  1622.  
  1623. (Using F_Readln of course.)  As it reads in each line, it uses 
  1624.  
  1625. next word to see if the line contains the word we're looking for.  
  1626.  
  1627. If it finds it, it writes the line number of the current line to 
  1628.  
  1629. the output file.  It then proceeds to look through the rest of the 
  1630.  
  1631. line and print out any remaining occurances of the word on that 
  1632.  
  1633. line.  It then moves on to the next line.  This one took about 45 
  1634.  
  1635. minutes to get running.  (And I don't know how many hours to add 
  1636.  
  1637. error checking, output formatting, etc.)
  1638.  
  1639.  
  1640.                            Main_Menu
  1641.  
  1642.      The Main_Menu routine is where everything else gets called 
  1643.  
  1644. from.  Basically it's just a simple dialog box with buttons.  When 
  1645.  
  1646. a button is pressed, the routine then calls the proper routine. 
  1647.  
  1648. When control is returned back to this routine, it clears the 
  1649.  
  1650. screen and calls the dialog again.
  1651.  
  1652.  
  1653.                              Finis
  1654.  
  1655.  
  1656.      Well that about wraps it up.  This program has taken up too 
  1657.  
  1658. much of my time in the last year.  But by having it around it's 
  1659.  
  1660. made writing my other programs that much easier (and then some!)  
  1661.  
  1662. Now that you have it, you can use it's advantages for your 
  1663.  
  1664. programs.  It may not be as important to writing programs as a 
  1665.  
  1666. good compiler, but it comes in tied for second with a good editor.
  1667.  
  1668.  
  1669.                             Appendix 
  1670.  
  1671.  
  1672.                    List of E_Format Defaults
  1673.       ====================================================
  1674.  
  1675.                             Returns
  1676.                 -------------------------------
  1677.      Return after const/var/type.  Yes.
  1678.      Return after comma.           No.
  1679.      Return before comma.          No.
  1680.      Return before and.            Yes.
  1681.      Return before or.             Yes.
  1682.  
  1683.      Preserve comma-return.        Yes.
  1684.      Strip blank lines.            No.
  1685.      Preserve Math Returns.        Yes.
  1686.      Add Return before BEGIN.      Yes.
  1687.      Add FF before procedures.     No.
  1688.  
  1689.                          Capitalization
  1690.                 -------------------------------
  1691.      Pascal Reserved  - Upper Case.
  1692.      Pascal Constants - Upper Case.
  1693.      Pascal Types     - Upper Case. 
  1694.      Pascal routines  - Upper Case. 
  1695.  
  1696.      GEM Const        - Upper Case.
  1697.      Gem Type         - Upper Case. 
  1698.      Gem Routines     - Upper Case. 
  1699.  
  1700.      Your words       - Lower Case. 
  1701.  
  1702.                             Tabbing
  1703.                 ------------------------------- 
  1704.  
  1705.      Tab after begin/procedure: 3.
  1706.      Tab before BEGIN:          1.
  1707.      Tab after Record:          3.
  1708.      Tab after DO:              3.
  1709.      Tab before then/else:      2.
  1710.      Tab after CONST/etc:       3.
  1711.      Tab before AND/OR:         2.
  1712.      Tab after case () of:      3.
  1713.      Tab for Nested Procedure:  3.
  1714.  
  1715.                            Appendix 2
  1716.  
  1717.              Dictionary for EPASUTIL.DAT word list.
  1718.  
  1719.      1= Pascal Reserved words.
  1720.      2= Pascal Constants.
  1721.      3= Pascal Types.
  1722.      4= Pascal Routines.
  1723.      5= GEM Constants.
  1724.      6= GEM Types.
  1725.      7= GEM Routines.
  1726.      8= Programmer defined words.
  1727.  
  1728.  
  1729.  
  1730.